<?php if(isset($default_feats)): ?>
	<form method="POST" action="<?php echo url_for('main/openProject?id='.$annoset->getId()); ?> ">
	<?php foreach($feats_lists as $layer_name=>$feats_types): ?>
		<h2>Feats types for <?php echo $layer_name; ?> </h2>
		<?php foreach($feats_types as $feats_type=>$feats_names): ?>
			<h3>Choose a default feat for <?php echo $feats_type; ?> : </h3>
			<p>
			<?php $first = true; ?>
			<?php foreach($feats_names as $feat_name=>$feat_values): ?>
				<input type="radio" name="<?php echo $layer_name.'['.$feats_type.']'; ?>" value="<?php echo $feat_name; ?>" 
				<?php if($first === true): ?>
					<?php $first = false; ?>
					checked="checked"
				<?php endif; ?>
				><?php echo $feat_name; ?><br/>
			<?php endforeach; ?>
			</p>
		<?php endforeach; ?>
	<?php endforeach; ?>
	<p>
	<input type="submit" value="ok"/>
	</p>
	</form>
<?php else: ?>
	<?php
	use_javascript('renderer.js'); 
	use_javascript('toolTip.js');
	use_javascript('displayLayer.js');
	use_javascript('editElement.js');
	use_javascript('lib/displayLayerTest.js');
	use_javascript('addDeleteElement.js');
	use_javascript('editSelect.js');
	use_javascript('editFeatDef.js');
	use_javascript('Open.js');
	use_javascript('importMediaProject.js');
	
	use_javascript('right_menu.js');
	?>
	
	<?php slot("toolbar");?>
	<div id="toolbar"></div>
	<?php end_slot();?>
	
	
	<?php slot("choice");?>
		<div class="ui-layout-west">
			<div class="">
				
				<div class="rightMenuMainPanel">
					Toolbox
					<span style="float:right">
						<img  title="minimize" class="CloseWest ui-corner-all" onclick="myLayout.close('west')" src="/images/minimize.png" />
					</span>
				</div>
				<div class="rightMenuPanel toolPannel">
					<span style="float:left">
						<img src="/images/down.png" />
					</span>
					Actions
				</div>
				<div class="rightMenuContent contentTool">
					<div class="rightMenuItem" id="selectTool">Select</div><br/>
					<div class="rightMenuItem" id="newTool">New</div><br/>				
					<div class="rightMenuItem" id="deleteTool">Delete</div><br/>
					<div class="rightMenuItem" id="linkTool">Link</div><br/>
				</div>
				<div class="rightMenuPanel delimiterPannel">
					<span style="float:left">
						<img src="/images/next.png" />
					</span>
					Delimiters
				</div>
				<div class="rightMenuContent contentDelimiter">
					<?php if($delimitersList->count() != 0): ?>
							<a class="dlmt" href="<?php echo url_for('main/openProject?id='.$annoset->getId().'&delimiter=#&index=1'); ?>">
								<div class="rightMenuItem" id="none">none</div><br/>
							</a>
							<?php foreach($delimitersList as $name):?>
							<a class="dlmt" href="<?php echo url_for('main/openProject?id='.$annoset->getId().'&delimiter='.$name['list_type'].'&index=1'); ?>">
								<div class="rightMenuItem" id="<?php echo $name['list_type'];?>"><?php echo $name['list_type'];?></div><br/>
							</a>
							<?php endforeach; ?>
							<script type="text/javascript">
							delimiter = "<?php echo $delimiter; ?>";
							setCurrentDlmt(delimiter);
							</script>
					<?php endif; ?>
				</div>
				<div class="rightMenuPanel layerPannel">
					<span style="float:left">
						<img src="/images/next.png" />
					</span>
					Layers
				</div>
				<div class="rightMenuContent contentLayer">
					<form id="hiddenLayers" action="<?php echo url_for('main/hideLayer'); ?>" method="post">
						<?php foreach($layers as $table=>$elements): ?>
							<?php foreach($elements as $element): ?>
								<input type="button" id="<?php echo $table; ?>" class="<?php echo $table; ?> selectedButton" value="<?php echo $element['list_type']; ?>"/><br/>
								<span id="<?php echo $element['list_type']; ?>State" style="display:none">visible</span>
							<?php endforeach; ?>
						<?php endforeach; ?>
					</form>
				</div>
				<span id="annoset" style="display:none"><?php echo $annoset->getId(); ?></span>
				<span id="annosetName" style="display:none"><?php echo $annoset->getName(); ?></span>
				<span id="currentUri" style="display:none"><?php echo $uri ?></span>
				<span id="resetUri" style="display:none"><?php echo url_for('main/resetElementsPosition?id='.$annoset->getId()) ?></span>
			</div>
		</div>
		<div class="ui-layout-south">
			<div id="information" style="position:absolute;right:0;padding:10px"></div>
			<div id="nav_bar">
				<div>
					<span style="padding:50px 2px"> Page </span>
					<span id="indice"></span>
					<span> of </span>
					<span id="total"></span>
				</div>
				<a href="#" id="first" title="first"><img border="white" class="paginationImage ui-corner-all" alt="Rewind" src="/images/start.png" /></a>
				<a href="#" id="previous" title="previous"><img border="white" class="paginationImage ui-corner-all" alt="Previous" src="/images/previous.png" /></a>
				<a href="#" id="next" title="next"><img border="white" class="paginationImage ui-corner-all" alt="Next" src="/images/next.png" /></a>
				<a href="#" id="last" title="last"><img border="white" class="paginationImage ui-corner-all" alt="Last" src="/images/finish.png" /></a>
			</div>	
			
		</div>


		<!-- <div class="ui-layout-east">

		</div> -->
		<input type="hidden" name="processingMode" value="ok" />
	<?php end_slot();?>
	<script type="text/javascript">
	<!--
		var colorNumber = 0;
	//-->
	</script>
	<?php foreach($listTypes as $type) : ?>
	<script type="text/javascript">
	<!--
	var type = "<?php  echo $type; ?>";
	colorNumberByType[type] = colorNumber;
	colorNumber ++;
	//-->
	</script>
	<?php endforeach; ?>
	<div id="whiteboard">
	<script type="text/javascript" language="javascript">
	initDisplay('whiteboard');
	var renderer = getRenderer();
	renderer.setSize(10000, 10000);
	var x = 0;
	var y = 0;
	var x_pos = 40; 
	var x_max = 0;
	var x_min = 0;
	var y_min = 0;
	var y_max = 0;
	var l = 0;
	var font_size = 15;
	var rect_height = font_size*1.4;
	var y_pos = 70 + parseInt('<?php echo $max_level; ?>')*(100 + rect_height);
	var canvas_width = 1600;
	var canvas_height = (y_pos > 1200) ? y_pos : 1200;
	var r,g,b;
	</script>

	<?php foreach($marks_level[0] as $entity): ?>
		<?php $mark = $entity['element']; ?>
		<?php if($mark->isToken()): ?>
			<?php $text = $mark->getText(ESC_RAW); ?>
			<?php if($mark->getXPosition()&&$mark->getYPosition()): ?>
				<script type="text/javascript">
				x = parseInt('<?php echo $mark->getXPosition(); ?>');
				y = parseInt('<?php echo $mark->getYPosition(); ?>');
				</script>
			<?php else :?>
				<script type="text/javascript">
				x = x_pos;
				y = y_pos;
				</script>
			<?php endif; ?>
			<script type="text/javascript" language="javascript">
			paula_id  = "<?php echo $mark->getPaulaId(); ?>";
			elementId = "<?php echo $mark->getId(); ?>"; 
			colorNumber = colorNumberByType['tok'];
			r = color[colorNumber]["r"];
			g = color[colorNumber]["g"];
			b = color[colorNumber]["b"];
			rect = new Graphic.Rectangle(renderer); 
			rect.setFill({r: 204, g: 204, b: 205, a: 128});
			rect.setStroke({r: r, g: g, b: b, a: 255});
			rect.setRoundCorner(10, 10);
			rect.translate(x, y);
			rect.setID('<?php echo $mark->getAttId(); ?>');
			rect.setTextValue("<?php echo $text; ?>", font_size);
			rect.setTextColor(r,g,b);
			rect.addFeat('paula_type', 'tok');
			rect.addFeat('paula_id', paula_id);
			rect.addFeat('elementId', elementId);
			size = rect.getSize();
			renderer.add(rect);
			x_pos += size['w'] + 10;
			canvas_width = x_pos;
			</script>
			<?php if(isset($feats_list[$mark->getPaulaId()], $feats_list[$mark->getPaulaId()][$mark->getAttId()])): ?>
				<?php foreach($feats_list[$mark->getPaulaId()][$mark->getAttId()] as $feat_id=>$feat_value):?>
				<script>
				feat_id = '<?php echo $feat_id;?>';
				feat_value = '<?php echo $feat_value?>';
				rect.addFeat(feat_id, feat_value);
				</script>
				<?php endforeach;?>
			<?php endif;?>
		<?php endif; ?>
	<?php endforeach; ?>

	<?php foreach($marks_level[0] as $entity): ?>
		<?php $mark = $entity['element']; ?>
		<?php if(!$mark->isToken()): ?>
			<?php
			if(isset($feats_list[$mark->getPaulaId()], $feats_list[$mark->getPaulaId()][$mark->getAttId()]))
				$text = $feats_list[$mark->getPaulaId()][$mark->getAttId()]->current(); /*for now take the first available feat*/
			else
				$text = $mark->getAttId();//default behaviour
			?>
			<?php if($mark->getXPosition()&&$mark->getYPosition()): ?>
				<script type="text/javascript">
				x = parseInt('<?php echo $mark->getXPosition(); ?>');
				y = parseInt('<?php echo $mark->getYPosition(); ?>');
				</script>
			<?php else :?>
				<script type="text/javascript">
				x = x_pos;
				y = y_pos;
				</script>
			<?php endif; ?>
			<script type="text/javascript" language="javascript"> 
			paula_type = "<?php echo $mark->getListType();?>";
			paula_id  = "<?php echo $mark->getPaulaId(); ?>";
			elementId = "<?php echo $mark->getId(); ?>"; 
			colorNumber = colorNumberByType[paula_type];
			r = color[colorNumber]["r"];
			g = color[colorNumber]["g"];
			b = color[colorNumber]["b"];      
			rect = new Graphic.Rectangle(renderer); 
			rect.setFill({r: 204, g: 204, b: 205, a: 128});
			rect.setStroke({r: r, g: g, b: b, a: 255});
			rect.setRoundCorner(10, 10);
			rect.translate(x, y);
			rect.setID('<?php echo $mark->getAttId(); ?>');
			rect.setTextValue("<?php echo $text; ?>", font_size);
			rect.setTextColor(r,g,b);
			rect.addFeat('paula_type', paula_type);
			rect.addFeat('paula_id', paula_id);
			rect.addFeat('elementId', elementId);
			size = rect.getSize();
			x_pos += size['w'] + 10;
			renderer.add(rect);
			canvas_width = x_pos;
			</script>
			<?php if(isset($feats_list[$mark->getPaulaId()], $feats_list[$mark->getPaulaId()][$mark->getAttId()])): ?>
				<?php foreach($feats_list[$mark->getPaulaId()][$mark->getAttId()] as $feat_id=>$feat_value):?>
				<script>
				feat_id = '<?php echo $feat_id;?>';
				feat_value = '<?php echo $feat_value?>';
				rect.addFeat(feat_id, feat_value);
				</script>
				<?php endforeach;?>
			<?php endif;?>
		<?php endif; ?>
	<?php endforeach; ?>
	
	<?php if(isset($structs_level[0])): ?>
	<?php foreach($structs_level[0] as $entity): ?>
		<?php $struct = $entity['element']; ?>
		<?php
			if(isset($feats_list[$struct->getPaulaId()], $feats_list[$struct->getPaulaId()][$struct->getAttId()]))
				$text = $feats_list[$struct->getPaulaId()][$struct->getAttId()]->current(); /*for now take the first available feat*/
			else
				$text = $struct->getAttId();
		?>
		<?php if($struct->getXPosition()&&$struct->getYPosition()): ?>
			<script type="text/javascript">
			x = parseInt('<?php echo $struct->getXPosition(); ?>');
			y = parseInt('<?php echo $struct->getYPosition(); ?>');
			</script>
		<?php else :?>
			<script type="text/javascript">
			x = x_pos;
			y = y_pos;
			</script>
		<?php endif; ?>
		<script type="text/javascript" language="javascript">
		var dx_pos = 0;
		var dy_pos = 0;
		paula_type = "<?php echo $struct->getListType();?>";
		paula_id  = "<?php echo $struct->getPaulaId(); ?>";
		elementId = "<?php echo $struct->getId(); ?>";
		colorNumber = colorNumberByType[paula_type];
		r = color[colorNumber]["r"];
		g = color[colorNumber]["g"];
		b = color[colorNumber]["b"];             
		rect = new Graphic.Rectangle(renderer);
		rect.setFill({r: 204, g: 204, b: 205, a: 128});
		rect.setStroke({r: r, g: g, b: b, a: 255});
		rect.setRoundCorner(10, 10);
		rect.translate(x, y); 
		rect.setID("<?php echo $struct->getAttId(); ?>");
		rect.setTextValue("<?php echo $text; ?>", font_size);
		rect.setTextColor(r,g,b);
		rect.addFeat('paula_type', paula_type);
		rect.addFeat('paula_id', paula_id);
		rect.addFeat('elementId', elementId);
		size = rect.getSize();
		renderer.add(rect);
		x_pos += size['w'] + 10;
		</script>
		<?php if(isset($feats_list[$struct->getPaulaId()], $feats_list[$struct->getPaulaId()][$struct->getAttId()])): ?>
			<?php foreach($feats_list[$struct->getPaulaId()][$struct->getAttId()] as $feat_id=>$feat_value):?>
			<script>
			feat_id = '<?php echo $feat_id;?>';
			feat_value = '<?php echo $feat_value?>';
			rect.addFeat(feat_id, feat_value);
			</script>
			<?php endforeach;?>
		<?php endif;?>			
	<?php endforeach; ?>
	<?php endif; ?>

	<script type="text/javascript" language="javascript">
	canvas_width = (x_pos > 1560) ? x_pos + 40 : 1600;
	var dx = (x_pos > 1600) ? 0 : (1600 - x_pos)/2;
	renderer.setSize(canvas_width, canvas_height);
	document.getElementById("whiteboard").style.width = canvas_width.toString()+"px";
	document.getElementById("whiteboard").style.height = canvas_height.toString()+"px";//*/
	</script>
	
	<?php foreach($marks_level as $level=>$entities): ?>
		<?php foreach($entities as $entity): ?>
			<?php if($entity['level'] != 0):?>
			<?php $mark = $entity['element']; ?>
				<?php
				if(isset($feats_list[$mark->getPaulaId()], $feats_list[$mark->getPaulaId()][$mark->getAttId()]))
					$text = $feats_list[$mark->getPaulaId()][$mark->getAttId()]->current(); /*for now take the first available feat*/
				else
					$text = $mark->getAttId();
				?>
				<?php if($mark->getXPosition()&&$mark->getYPosition()): ?>
					<script type="text/javascript">
					x = parseInt('<?php echo $mark->getXPosition(); ?>');
					y = parseInt('<?php echo $mark->getYPosition(); ?>');
					</script>
				<?php else :?>
					<script type="text/javascript">
					x = x_pos;
					y = y_pos;
					</script>
				<?php endif; ?>
				<script type="text/javascript" language="javascript"> 
				paula_type = "<?php echo $mark->getListType();?>"; 
				paula_id = "<?php echo $mark->getPaulaId();?>";
				elementId = "<?php echo $mark->getId(); ?>";
				colorNumber = colorNumberByType[paula_type];
				r = color[colorNumber]["r"];
				g = color[colorNumber]["g"];
				b = color[colorNumber]["b"];       
				rect = new Graphic.Rectangle(renderer); 
				rect.setFill({r: 204, g: 204, b: 205, a: 128});
				rect.setStroke({r: r, g: g, b: b, a: 255});
				rect.setRoundCorner(10, 10);
				rect.translate(x, y);
				rect.setID('<?php echo $mark->getAttId(); ?>');
				rect.setTextValue("<?php echo $text; ?>", font_size);
				rect.setTextColor(r,g,b);
				rect.addFeat('paula_type', paula_type);
				rect.addFeat('paula_id', paula_id);
				rect.addFeat('elementId', elementId);
				size = rect.getSize();
				x_pos += size['w'] + 10;
				renderer.add(rect);
				</script>
				<?php if(isset($feats_list[$mark->getPaulaId()], $feats_list[$mark->getPaulaId()][$mark->getAttId()])): ?>
					<?php foreach($feats_list[$mark->getPaulaId()][$mark->getAttId()] as $feat_id=>$feat_value):?>
					<script>
					feat_id = '<?php echo $feat_id;?>';
					feat_value = '<?php echo $feat_value?>';
					rect.addFeat(feat_id, feat_value);
					</script>
					<?php endforeach;?>
				<?php endif;?>
			<?php endif; ?>
		<?php endforeach; ?>
	<?php endforeach; ?>
	
	<?php foreach ($structs_level as $level=>$entities):?>
		<?php foreach($entities as $entity): ?>
			<?php if($entity['level'] != 0): ?>
				<?php $struct = $entity['element']; ?>
				<?php
					if(isset($feats_list[$struct->getPaulaId()], $feats_list[$struct->getPaulaId()][$struct->getAttId()]))
						$text = $feats_list[$struct->getPaulaId()][$struct->getAttId()]->current(); /*for now take the first available feat*/
					else
						$text = $struct->getAttId();
				?>
				<?php if($struct->getXPosition()&&$struct->getYPosition()): ?>
					<script type="text/javascript">
					x = parseInt('<?php echo $struct->getXPosition(); ?>');
					y = parseInt('<?php echo $struct->getYPosition(); ?>');
					</script>
				<?php else :?>
					<script type="text/javascript">
					x = x_pos;
					y = y_pos;
					</script>
				<?php endif; ?>			
				<script type="text/javascript" language="javascript">
				var dx_pos = 0;
				var dy_pos = 0;
				paula_type = "<?php echo $struct->getListType();?>";
				paula_id = "<?php echo $struct->getPaulaId();?>";
				elementId = "<?php echo $struct->getId(); ?>";
				colorNumber = colorNumberByType[paula_type];
				r = color[colorNumber]["r"];
				g = color[colorNumber]["g"];
				b = color[colorNumber]["b"];                   
				rect = new Graphic.Rectangle(renderer);
				rect.setFill({r: 204, g: 204, b: 205, a: 128});
				rect.setStroke({r: r, g: g, b: b, a: 255});
				rect.setRoundCorner(10, 10);
				rect.translate(x, y); 
				rect.setID("<?php echo $struct->getAttId(); ?>");
				rect.setTextValue("<?php echo $text; ?>", font_size);
				rect.setTextColor(r,g,b);
				rect.addFeat('paula_type', paula_type);
				rect.addFeat('paula_id', paula_id);
				rect.addFeat('elementId', elementId);
				size = rect.getSize();
				renderer.add(rect);
				x_pos += size['w'] + 10;
				</script>
				<?php if(isset($feats_list[$struct->getPaulaId()], $feats_list[$struct->getPaulaId()][$struct->getAttId()])): ?>
					<?php foreach($feats_list[$struct->getPaulaId()][$struct->getAttId()] as $feat_id=>$feat_value):?>
					<script>
					feat_id = '<?php echo $feat_id;?>';
					feat_value = '<?php echo $feat_value?>';
					rect.addFeat(feat_id, feat_value);
					</script>
					<?php endforeach;?>
				<?php endif;?>	
			<?php endif; ?>
		<?php endforeach; ?>	
	<?php endforeach; ?>

	<?php
	$marks_level->rewind();
	$structs_level->rewind();
	?>




	<?php foreach($marks_level as $level=>$entities): ?>
		<?php foreach($entities as $mark): ?>
			<?php if($mark['level'] != 0):?>
				<script type="text/javascript" language="javascript">
					var first = true;
					rect = renderer.get("<?php echo $mark['element']->getAttId(); ?>");
					paula_type = rect.getFeat('paula_type');
				</script>	
				<?php foreach ($mark['sons'] as $son): ?>
					<?php if(in_array($son['son']->getAttId(), $att_ids_list->getRawValue())): ?>			
					<script type="text/javascript" language="javascript">
					var rectTo = renderer.get("<?php echo $son['son']->getAttId(); ?>");
					if(first === true)
					{
						first = false;
						init_y_pos = rectTo.getMatrix()['dy'];
						y_min = init_y_pos;
						y_max = init_y_pos;
						x_min = rectTo.getMatrix()['dx'];
						x_max = rectTo.getMatrix()['dx'] + rectTo.getSize()['w'];		
					}
					end_y_pos = rectTo.getMatrix()['dy'];
					if(end_y_pos < y_min)
						y_min = end_y_pos;
					if(end_y_pos > y_max)
						y_max = end_y_pos;
					if((rectTo.getMatrix()['dx'] + rectTo.getSize()['w'])>x_max)
						x_max = rectTo.getMatrix()['dx'] + rectTo.getSize()['w']; 
					colorNumber = colorNumberByType[paula_type];
					r = color[colorNumber]["r"];
					g = color[colorNumber]["g"];
					b = color[colorNumber]["b"];  
					var line = new Graphic.Line(renderer); 
					line.setPoints(rect.getMatrix()["dx"]+rect.getSize()["w"]/2
						, rect.getMatrix()["dy"]+rect.getSize()["h"]
						, rectTo.getMatrix()["dx"]+rectTo.getSize()["w"]/2
						, rectTo.getMatrix()["dy"]);
					line.setStroke({r: r, g: g, b: b, a: 128, w: 2});
					line.setID("l"+l);
					l +=1 ; 
					line.setFrom(rect.getID());
					line.setTo(rectTo.getID());
					rect.addLineFrom(line.getID(),rectTo.getID());
					rectTo.addLineTo(line.getID(),rect.getID());
					renderer.add(line);
					renderer.moveToBack(line);
					</script>
					<?php endif; ?>			
				<?php endforeach; ?>
				<?php if(!($mark['element']->getXPosition()&&$mark['element']->getYPosition())): ?>		
				<script type="text/javascript" language="javascript">
				rect.setPosition((x_min + x_max - rect.getSize()['w'])/2 , y_max - (100 + rect_height));
				</script>
				<?php endif; ?>	
			<?php endif; ?>
		<?php endforeach; ?>
	<?php endforeach; ?>

	<?php foreach ($structs_level as $level=>$entities):?>
		<?php foreach($entities as $struct): ?>
			<?php if($struct['level'] != 0): ?>	
				<?php $paula_id = $struct['element']->getPaulaId(); ?>	
				<script type="text/javascript" language="javascript">
				var first = true;
				rect = renderer.get("<?php echo $struct['element']->getAttId(); ?>");
				paula_type = rect.getFeat('paula_type');
				</script>	
				<?php foreach ($struct['sons'] as $son): ?>	
					<?php if(in_array($son['son']->getAttId(), $att_ids_list->getRawValue())): ?>	
					<?php
					$rel_id = $son['rel_id'];
					if(isset($feats_list[$paula_id], $feats_list[$paula_id][$rel_id]))
						$link_text = $feats_list[$paula_id][$rel_id]->current();/*for now take the first available feat*/
					else
						$link_text = '';
					?>		
					<script type="text/javascript" language="javascript">
					var rectTo = renderer.get("<?php echo $son['son']->getAttId(); ?>");
					rel_id = "<?php echo $son['idRel']; ?>";
					if(first === true)
					{
						first = false;
						init_y_pos = rectTo.getMatrix()['dy'];
						y_min = init_y_pos;
						y_max = init_y_pos;
						x_min = rectTo.getMatrix()['dx'];
						x_max = rectTo.getMatrix()['dx'] + rectTo.getSize()['w'];		
					}
					end_y_pos = rectTo.getMatrix()['dy'];
					if(end_y_pos < y_min)
						y_min = end_y_pos;
					if(end_y_pos > y_max)
						y_max = end_y_pos;
					if((rectTo.getMatrix()['dx'] + rectTo.getSize()['w'])>x_max)
						x_max = rectTo.getMatrix()['dx'] + rectTo.getSize()['w']; 
					colorNumber = colorNumberByType[paula_type];
					r = color[colorNumber]["r"];
					g = color[colorNumber]["g"];
					b = color[colorNumber]["b"];  	
				  var line = new Graphic.Line(renderer); 
					line.setPoints(rect.getMatrix()["dx"]+rect.getSize()["w"]/2
						, rect.getMatrix()["dy"]+rect.getSize()["h"]
						, rectTo.getMatrix()["dx"]+rectTo.getSize()["w"]/2
						, rectTo.getMatrix()["dy"]);
				  line.setStroke({r: r, g: g, b: b, a: 128, w: 2});
				  line.setID(rel_id);
				  line.setFrom(rect.getID());
				  line.setTo(rectTo.getID());
				  line.setText("<?php echo $link_text; ?>", r, g, b);
				  rect.addLineFrom(line.getID(),rectTo.getID());
				  rectTo.addLineTo(line.getID(),rect.getID());
				  renderer.add(line);
				  renderer.moveToBack(line);
					</script>
					<?php endif;?>	
				<?php endforeach; ?>
				<?php if(!($struct['element']->getXPosition()&&$struct['element']->getYPosition())): ?>		
				<script type="text/javascript" language="javascript">
				rect.setPosition((x_min + x_max - rect.getSize()['w'])/2 , y_min - (100 + rect_height));
				</script>
				<?php endif; ?>
			<?php endif; ?>
		<?php endforeach; ?>	
	<?php endforeach; ?>
	</div>
<?php $url_base = 'main/openProject?id='.$annoset->getId().'&delimiter='.$delimiter.'&index=';?>
<script type="text/javascript">
<!--
var index = <?php echo $index; ?>;
var total = <?php echo $total; ?>;
var url_base = "<?php echo url_for($url_base); ?>";
displayLayerTest(index, total, url_base);
//-->
</script>






<?php /* 
<script type="text/javascript" language="javascript">
<!--
var index = <?php echo $index; ?>;
var total = <?php echo $total; ?>;
var url_base = "<?php echo url_for('test/featsTest?index='); ?>";
url_next = url_base+(index+1).toString();
url_previous = url_base+(index - 1).toString();

jQuery("#indice").text(index);
jQuery("#total").text(total);

if(index < total)
	jQuery("#next").attr("href", url_next);
else
	jQuery("#next").attr("href", "#");
if(index > 1)
	jQuery("#previous").attr("href", url_previous);
else
	jQuery("#previous").attr("href", '#');
//-->
</script>
//*/?>
	
<?php endif; ?>

